Skip to content

test: migrate math/base/special/cscd to ULP-based assertions - #14313

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-cscd
Aug 16, 2026
Merged

test: migrate math/base/special/cscd to ULP-based assertions#14313
kgryte merged 1 commit into
developfrom
kgryte/ulp-cscd

Conversation

@kgryte

@kgryte kgryte commented Aug 16, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for math/base/special/cscd from relative tolerance testing (delta <= tol, where tol = 1.4 * EPS * abs( expected[ i ] )) to ULP difference testing using @stdlib/assert/is-almost-same-value.

Both test/test.js and test/test.native.js are updated. In each file, the two fixture loops (negative and positive values) now assert

t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' );

The now-unused @stdlib/constants/float64/eps and @stdlib/math/base/special/abs requires are removed, and the @stdlib/assert/is-almost-same-value require is added. The pre-existing expected[ i ] === null branches (which assert exact -Infinity/+Infinity returns at multiples of 180) are left unchanged, as those are exact comparisons rather than tolerance-based ones.

ULP constant

The measured minimum ULP value is 2, used in all four converted fixture loops:

File Test ULP
test/test.js negative values 2
test/test.js positive values 2
test/test.native.js negative values 2
test/test.native.js positive values 2

The bound was tightened by measuring the exact worst-case ULP difference over the full Julia fixture sets (999 non-null cases per set): the maximum observed difference is exactly 2 ULP in both the negative and positive sets, and the suite fails at 1 ULP. The test suite was run twice at the final value to confirm determinism (2009 passing assertions, no failures, both runs).

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

test/test.native.js uses the same 2 ULP bound as test/test.js. The native addon was not built in the environment used to author this change, so those tests were skipped locally and the C implementation's ULP behavior was not measured directly. The bound mirrors the JavaScript measurement on the grounds that both implementations are the same expression (1.0 / sind( x ) in lib/main.js and stdlib_base_cscd in src/main.c). Happy to adjust if reviewers would prefer a separately measured value for the native tests.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

The conversion mirrors the idiom already used by the sibling package math/base/special/cotd, which has the same fixture structure, including the null special-case branches.

Verification performed:

  • make test TESTS_FILTER=".*/math/base/special/cscd/.*" — passing (run twice)
  • make eslint-tests TESTS_FILTER=".*/math/base/special/cscd/.*" — clean
  • only the two test files are modified

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was written by Claude Code running as an unattended scheduled task. The tolerance-to-ULP conversion, the ULP bound search, and the local verification runs were all performed by the agent.


@stdlib-js/reviewers


Generated by Claude Code

@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Good First PR A pull request resolving a Good First Issue. labels Aug 16, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/cscd $\\color{green}186/186$
$\\color{green}+100.00\\%$
$\\color{green}5/5$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}186/186$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Aug 16, 2026
@kgryte
kgryte marked this pull request as ready for review August 16, 2026 03:53
@kgryte
kgryte requested a review from a team August 16, 2026 03:53
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 16, 2026
@kgryte
kgryte merged commit 317a098 into develop Aug 16, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-cscd branch August 16, 2026 03:54
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue. Math Issue or pull request specific to math functionality. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants